package org.hot100.h011;

/**
 * @Author: wjy
 * @Date: 2021/12/9 11:09
 */
public class Solution {

    public static void main(String[] args) {

        int[] ints = {1,8,6,2,5,4,8,3,7};

        Solution solution = new Solution();
        System.out.println(solution.maxArea(ints));

    }

    public int maxArea(int[] height) {
        if (height.length == 0) {
            return 0;
        }

        int left = 0, right = height.length - 1, max = 0;

        while (left < right) {

            max = Math.max(max, height[left] <= height[right] ? (right - left) * height[left++] : (right - left) * height[right--]);

        }
        return max;

    }

}
